/**
 * @author scylla
 * @version V1.0
 * @Project echo-java-base
 * @Title 中途加入的线程
 * @Description *
 * @Package concurrent.mthread.join
 * @Since 2021/8/3 10:03 上午
 */
package concurrent.mthread.join;

import java.text.MessageFormat;

public class Joiner extends Thread {

    private Sleeper sleeper;

    public Joiner(String name, Sleeper sleeper) {
        super(name);
        this.sleeper = sleeper;
        start();
    }

    @Override
    public void run() {
        try {
            sleeper.join();
        } catch (InterruptedException e) {
            System.out.println(e.getMessage());
        }

        System.out.println(MessageFormat.format("{0} join completed", getName()));
    }
}
